package com.ipc.admin.service.gwl.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ipc.admin.service.gwl.service.SecondScreenDetailService;
import com.ipc.common.pojo.bo.gwl.PageAndSearchBo;
import com.ipc.common.pojo.bo.gwl.SecondScreenDetailBo;
import com.ipc.common.pojo.vo.R;
import com.ipc.core.dao.gwl.dao.SecondScreenDetailDao;
import com.ipc.core.entity.gwl.SecondScreenDetail;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 三级诱导屏详情(SecondScreenDetail)表服务实现类
 *
 * @author 高万里
 * @since 2023-05-02 10:50:15
 */
@Service("secondScreenDetailService")
public class SecondScreenDetailServiceImpl implements SecondScreenDetailService {

    @Resource
    private SecondScreenDetailDao dao;
    
     @Override
    public R add(SecondScreenDetail secondScreenDetail) {
//        if (dao.getNo() != null) {
//            return R.fail("此编号已存在！");
//        }
        return R.ok(dao.insert(secondScreenDetail));
    }

    @Override
    public R del(List<Long> idList) {
        if (dao.deleteBatchIds(idList) > 0) {
            return R.ok();
        }
        return R.fail("删除失败");
    }

    @Override
    public R update(SecondScreenDetail secondScreenDetail) {
        return R.ok(dao.updateById(secondScreenDetail));
    }

    @Override
    public R selectOne(int id) {
        return R.ok(dao.selectById(id));
    }

    @Override
    public R selectAllPark(int id) {
        return R.ok(dao.selectAllPark(id));
    }

    @Override
    public R selectAll(PageAndSearchBo bo) {
        PageHelper.startPage(bo.getPage(), bo.getSize());
        PageInfo<SecondScreenDetailBo> pageInfo = new PageInfo<>(dao.selectAll(bo.getId()));
        return R.ok(pageInfo);
    }

}

